﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;

using CloudSoft.Workflows;

namespace ERPStore.Exporter.Workflows.Activities
{

	public sealed class CreateDocument : CodeActivity
	{
		public InArgument<Providers.IExport> ExportArgument { get; set; }

		protected override void Execute(CodeActivityContext context)
		{
			var export = context.GetValue(ExportArgument);
			export.CreateDocument();
			context.ReportProgress(string.Format("start generate file for {0}", export.Settings.FileName));

			var publisher = context.GetService<EventBrokR.IPublisher>();

			var @event = new ERPStore.Events.GlobalEvent()
			{
				EventName = "ComparatorProductListCreated",
				Source = export.LeadSource,
			};
			publisher.PublishAsync(@event);

			export.Settings.ProductCount = 0;
		}
	}
}
